<?php
require_once 'db.php';

class Users extends DB {
    private $_table_name = 'users';
    private $_query = '';
    public $users;
    
    public function __construct() {
        $this->getConnection();
    }
    
    public function select() {
        $query = 'SELECT * FROM '.$this->_table_name;
        //Query data
        $users = array();
        $results = $this->query($query);
        while ($row = mysql_fetch_assoc($results)) {
            $users[] = $row;
        }
        $this->users = $users;
        return $users;
    }
    public function isValid($users) {
        $flag = FALSE;
        for ($i = 0; $i < count($this->users); $i++) {
            if ((strcmp($users['username'], $this->users[$i]['name']) == 0) && 
                (strcmp(md5($users['password']), $this->users[$i]['password']) == 0)) {
                break;
            }
        }
        return $flag;
    }
}
?>
